var $dialog_error;
$(function() {
    $dialog_error = $('#dialog_error');
    
    $( "input[type=submit], button" )
        .button()
        .click(function( event ) {
            event.preventDefault();
    });
    
    $('.memu').memu({ 
        icon: {
            inset: true,
            margin: {
                top: 0,
                right: 3
            }
        },
        width: 250,
        rootWidth: 0,
        height: 32
    });
    
    dialogError();
});

function dialogError(){
    $dialog_error.dialog({
        //height: 300,
        width: 400,
        autoOpen: false,
        resizable: true,
        modal: true,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
            }
        }
    });
}

function input_number(){
    $("input.input-number").unbind('keydown').keydown(function(e){
        //console.log(e.keyCode);
        var flag = e.keyCode >= 48 && e.keyCode <= 57;
        flag |= e.keyCode == 8;
        flag |= e.keyCode == 190; // dot
        flag |= e.keyCode == 110; // dot
        flag |= e.keyCode == 35; // END
        flag |= e.keyCode == 36; // HOME
        flag |= (e.keyCode >= 37 && e.keyCode <= 40);
        flag |= (e.keyCode >= 96 && e.keyCode <= 105);
        flag |= e.which >= 48 && e.which <= 57;
        //flag |= e.which == 8;//Backspace
        flag |= (e.which >= 37 && e.which <= 40);
        flag |= (e.which >= 96 && e.which <= 105);
        flag |= e.keyCode == 13;//Enter
        flag |= e.which == 46;//Delete
        if(flag != true && flag != 1){
            return false;
        }
    });
}

function input_price(){
    $("input.input-price").unbind('keydown').keydown(function(e){
        //console.log(e.keyCode);
        var flag = e.keyCode >= 48 && e.keyCode <= 57;
        flag |= e.keyCode == 8;
        //flag |= e.keyCode == 190; // dot
        //flag |= e.keyCode == 110; // dot
        flag |= e.keyCode == 35; // END
        flag |= e.keyCode == 36; // HOME
        flag |= (e.keyCode >= 37 && e.keyCode <= 40);
        flag |= (e.keyCode >= 96 && e.keyCode <= 105);
        flag |= e.which >= 48 && e.which <= 57;
        //flag |= e.which == 8;//Backspace
        flag |= (e.which >= 37 && e.which <= 40);
        flag |= (e.which >= 96 && e.which <= 105);
        flag |= e.keyCode == 13;//Enter
        flag |= e.which == 46;//Delete
        if(flag != true && flag != 1){
            return false;
        }
    });
}